home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1426 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: ub239.dialup.uwa.edu.au!not-for-mail
  2. From: prye@cyllene.uwa.edu.au (Peter Rye)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is wrong in this code?
  5. Date: 14 Jan 1996 02:46:08 +0800
  6. Organization: The University of Western Australia
  7. Message-ID: <4d8ulg$ad@ub239.dialup.uwa.edu.au>
  8. References: <DL2z7o.2K5@scisun.sci.ccny.cuny.edu> <4d7kvv$j8@ub239.dialup.uwa.edu.au>
  9. NNTP-Posting-Host: ub239.dialup.uwa.edu.au
  10.  
  11. prye@cyllene.uwa.edu.au (Peter Rye) writes:
  12.  
  13. Oops!! Sorry I think I've written some rubbish.
  14.  
  15. >>x = pow(x,x);
  16. > ^-------------------- This line is a problem.
  17. >                       I believe this will give rise to 
  18. >                       "undefined behavior" because you 
  19. >                       are modifying x using a function
  20. >                       which takes x as an argument.
  21. >                       Use something like y = pow(x,x);
  22. >                       Where y is declared as a double,
  23. >                       then use y in the printf below. 
  24.  
  25. Having thought about this further I think this is legal code.
  26. Sorry!!!
  27.  
  28. -- 
  29. | Peter Rye                                                           |
  30. | Respiratory Research Fellow                                         |
  31. | Princess Margaret Hospital for Children                             |
  32. | Perth, Western Australia                                            |
  33.